<template>
	<view>
		<nvaigaionbar :title="nvaigaionbar.title"></nvaigaionbar>
		<view class="container">
			<view class="content">
				<view class="title">
					<text>选择城市</text>
				</view>
				<view class="currentCity">
					<text>当前城市</text>
					<text>{{currentCity}}</text>
				</view>
				<view>
					<view v-for="(item1,index1) in dataCity" :key="index1" class="cityList">
						<text>{{item1.title}}</text>
						<view class="cityName">
							<text v-for="(item2,index2) in item1.lists" :key="index2" @click="selCity(item2)">{{item2}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import nvaigaionbar from '../navigationBar.vue'
	export default {
		components: {
			nvaigaionbar
		},
		data() {
			return {
				nvaigaionbar: {
					title: '城市'
				},
				currentCity: '上海',
				dataCity: '',
			}
		},
		onLoad() {
			this.currentCity = this.$store.state.currentCity
			uniCloud.callFunction({
				name: 'getCityData',
				success:(res) => {
					this.dataCity = res.result.data
				}
			})
		},
		methods: {
			selCity(data) {
				uni.navigateBack({
					delta: 1
				})
				this.$store.commit('setCity', data)
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		.content {
			width: 90%;
			margin: 0 auto;
			.title {
				margin-top: 50rpx;
				font-size: 50rpx;
			}
			.currentCity {
				width: 100%;
				margin: 40rpx 0 30rpx;
				font-size: 30rpx;
				padding-bottom: 20rpx;
				& text:nth-of-type(1) {
					display: block;
					margin-bottom: 40rpx;
					font-size: 40rpx;
				}
				& text:nth-of-type(2) {
					background-color: #eaeaea;
					padding: 15rpx;
					border-radius: 10rpx;
				}
			}
			.cityList {
				margin-top: 30rpx;
				&>text {
					display: block;
					font-size: 40rpx;
					margin-bottom: 30rpx;
				}
				.cityName {
					text{
						color: #535353;
						display: inline-block;
						padding: 15rpx 20rpx;
						border-radius: 10rpx;
						margin: 0 30rpx 25rpx 0;
						background-color: #eaeaea;
					}
				}
			}
		}
	}
</style>
